import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Demo{
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch nucleinCountDownLatch = new CountDownLatch(5);
        System.out.println("开始做核酸啦~~~");
        ExecutorService executorService = Executors.newCachedThreadPool();
        for (int i = 0; i < 5; i++) {
            final int j = i;
            executorService.execute(() -> {
                System.out.println("user" + j + " "+ LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) + "做完了核酸");
                nucleinCountDownLatch.countDown();
            });
            Thread.sleep(2000);
        }
        nucleinCountDownLatch.await();
        System.out.println("核算员着急忙慌的下班了, 可担心再来一个做核酸的....");
        executorService.shutdown();
    }
}